/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package gabriel.bancodedados;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;

/**
 *
 * @author Gabriel
 */
public class CriaConexao {

//    public static Connection getConexao() throws SQLException {
//        try {
//            Class.forName("com.mysql.jbdc.Driver");
//            System.out.println("Conectando ao banco de dados");
//            return DriverManager.getConnection("jdbc:mysql://localhost/agendabd", "root", "admin");
//        } catch (ClassNotFoundException e) {
//            throw new SQLException(e.getMessage());
//        }
//    }
    
    public Connection getConnection() throws SQLException {
        Connection con = null;
        con = DriverManager
                .getConnection("jdbc:mysql://localhost/agendabd?user=root&password=admin");
        System.out.println("Conectado ao banco de dados");
        return con;
    }
    //oi
 
    public void closeConnnection(Connection con) {
        try {
            con.close();
        } catch (SQLException e) {
            e.printStackTrace();
        }
    }

}
